package com.wanmait.recycle.webcontroller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wanmait.recycle.pojo.Rubbish;
import com.wanmait.recycle.service.RubbishService;
import com.wanmait.recycle.util.Pager;

@Controller
@RequestMapping("web/rubbish")
public class WebFenLeiSeachController {

	@Resource
	private RubbishService rubbishService;

	@RequestMapping("seachResult")
	public ModelAndView result(String keyword,Integer pageNo) {
		ModelAndView mv = new ModelAndView();
		
		if(keyword==null || keyword.trim().equals(""))
		{
			mv.setViewName("redirect:/index");
			return mv;
		}
		Pager pager = new Pager();
		if(pageNo!=null)
		{
			pager.setPageNo(pageNo);
		}
		pager.setPageSize(5);
		List<Rubbish> rubbishs = rubbishService.seachBySolr(keyword,pager);
		mv.addObject("rubbishs", rubbishs);
		mv.addObject("pager",pager);
		mv.addObject("keyword",keyword);
		return mv;
		
	}
}











